<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//4. 根据课件动物类的例子，尝试定义更多的动物重写sound方法，比如：狗、猫等，至少3种。
			function Animal(type) {
				this.type = type;
			}
			Animal.prototype.sound = function() {
				console.log(this.type + this.name + "发出叫声");
			}

			function F() {}
			F.prototype = Animal.prototype;

			function Dw(name,type) {
				Animal.call(this, type);
				this.name = name;
			}

			Dw.prototype = new F();
			Dw.prototype.constructor = Dw;

			Dw.prototype.sound = function() {
				console.log(this.type + this.name + "汪汪的叫");
			}

			let dog = new Dw("查理","小狗");
			console.log(dog);
			dog.sound();
			
			Dw.prototype.sound = function() {
				console.log(this.type + this.name + "喵喵的叫");
			}
			
			let cat = new Dw("斑点","小猫");
			console.log(cat);
			cat.sound();
			
			Dw.prototype.sound = function() {
				console.log(this.type + this.name + "咩咩的叫");
			}
			
			let sheep= new Dw("肖恩","小羊");
			console.log(sheep);
			sheep.sound();
		</script>
	</body>
</html>
